package com.mystyle.le.weekproject.activity;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;

import com.mystyle.le.weekproject.R;
import com.mystyle.le.weekproject.adapter.TalkCollectCursorAdapter;
import com.mystyle.le.weekproject.beans.TalkList;
import com.mystyle.le.weekproject.sqlite.TilkSqlite;

import java.util.ArrayList;
import java.util.List;

public class TalkCollectActivity extends AppCompatActivity {

    private ListView dingbu_talkTV;
    private SQLiteDatabase database;
    private TilkSqlite tilkSqlite;
    private List<TalkList> lists;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_talk_collect);
        //初始化控件
        initView();
    }

    private void initView() {
        dingbu_talkTV = ((ListView) findViewById(R.id.talk_cottect_LV));

        lists = new ArrayList<>();
        tilkSqlite = new TilkSqlite(TalkCollectActivity.this);
        database = tilkSqlite.getReadableDatabase();
        String sql = "select *from data";
        Cursor cursor = database.rawQuery(sql,null);//查询数据库
        TalkCollectCursorAdapter talkCollectCursorAdapter = new TalkCollectCursorAdapter(TalkCollectActivity.this, cursor);
        dingbu_talkTV.setAdapter(talkCollectCursorAdapter);
    }
}
